"""
字典:
    1.字典的创建
"""

print("---字典的创建")
dct = {"键":"值"}
print(dct)
# 使用dict函数必须要有映射关系
dct = dict([(1,2),(3,4),(5,6)])
dct = dict([[1,2],[3,4],[5,6]])
print(dct)

# 把列表转成字典
l1 = ["uname","upwd","balance"]
l2 = ["张三","123","1000"]
# 字典的键是必须要有的.值可以不存在的
dct = {}
for index,key in enumerate(l1):
    dct[key] = l2[index]
print(dct)

dct = {}
for i in range(len(l1)):
    dct[l1[i]] = l2[i]
print(dct)


dct = dict(zip(l1,l2))
print(type(dct))
print(dct)

# 有字典转换成列表
# keys() 获取所有的键 values() 获取所有的值
key = dct.keys()
value = dct.values()
print(list(key),type(key))
print(list(value),type(value))







